<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE html>
<html>
<head>
    <title>公告管理</title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp" %>  
    <!--[if lt IE 9]>
        <script src="${ctx}/lib/js/html5shiv.min.js"></script>
        <script src="${ctx}/lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
							
    <section class="content-header">
        <h1>公告管理</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">药品招标管理</a></li>
            <li class="active"><a href="#">招标公告管理</a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="form-inline">
                    <div class="form-group form-group-xs">
                        <label for="sysNoticeTitle">公告标题：</label>
                        <input class="form-control" type="text" id="sysNoticeTitle" placeholder="公告标题" maxlength="100" />
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="sysNoticeDateTime">发布日期：</label>
                        <input class="form-control" type="text" name="startPoint" id="startPoint" placeholder="开始日期" data-provide="datepicker" data-date-fmt="yyyy-MM-dd"/>
                        <label>-</label>
                        <input class="form-control" type="text" name="endPoint" id="endPoint" placeholder="结束日期" data-provide="datepicker" data-date-fmt="yyyy-MM-dd" />
                    </div>
                 
					<div class="form-group form-group-xs">
						<label>公告状态：</label> <select class='form-control' id="status"
							style="width: 100px;">
							<option value="">请选择</option>
							<option value="1">已发布</option>
							<option value="0">未发布</option>
						</select>
					</div>
                    <button type="button" class="btn btn-success btn-sm" onclick="search();">查&nbsp;询</button>
                </div>
            </div>
        </div>
        
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        
        <div class=" box box-warning bottongroup">
             <a href="toEditSysNotice.html?opType=2&projId=${projId }" class="btn btn-default btn-sm">新&nbsp;增</a>
             <a href="javascript:batchChangeStatus(1)" class="btn btn-default btn-sm">发&nbsp;布</a>
             <c:if test="${defaultProjId == null}">
             	<a href="toSysNoticeList.html" class="btn btn-default btn-sm">返&nbsp;回</a>
             </c:if>
        </div>
  
    </section>
     <%@ include file="/WEB-INF/component/commonJS.jsp" %>  
    <script type="text/javascript">
        function url(url){
        	window.top.location.href=url;
        }
    	function changeStatus(id, status) {
    		var msg = "发布";
    		if(status == 1){
    			msg = "启用";
    		}
    		$.HN.message.confirm("确定"+msg+"吗？", '', '').on(function (e) {
                if (e) {
    		$.post("changeStatusOfDrugQualitySpec.html", {
    			stdDrugQualitySpecId : id,
    			status : status
    		}, function(result) {
    			if (result.success) {
    				var curpage = $("#gridlist").jqGrid('getGridParam', 'page');
    				search(curpage);
    				$.HN.message.alert("保存成功！", "消息", "success");
    			} else {
    				$.HN.message.alert("操作失败！", "消息", "error");
    			}
    		}, "json")
                }
    		});
    	}
    	function batchChangeStatus(status) {
    		var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
    		if (rowIds.length <= 0) {
    			$.HN.message.alert("请选择要操作的行！", "提示消息", "warn");
    			return;
    		}
    		var str = "";
			var overId = "";
			for (var i = 0; i < rowIds.length; i++) {
				str += rowIds[i] + ",";
				var rowdata = $("#gridlist").jqGrid(
						'getRowData', rowIds[i]);
				overId += rowdata.sysNoticId + ",";
			}
			if (str.length > 0) {
				str = str.substring(0, str.length - 1);
			}
			$.HN.message.confirm("确定发布吗？", '', '').on(function (e) {
                if (e) {
    		$.post("batchReleaseSysNotice.html", {
    			"overId" : overId,
    			"status" : status
    		}, function(result) {
    			if (result.success) {
    				var curpage = $("#gridlist").jqGrid('getGridParam', 'page');
    				search(curpage);
    				$.HN.message.alert("发布成功！", "消息", "success");
    			} else {
    				$.HN.message.alert("发布失败！", "消息", "error");
    			}
    		}, "json")
                }
    		});
    	}
    	
    	function search(page) {
    		var sysNoticeTitle = $.trim($("#sysNoticeTitle").val());
    		var startPoint = $.trim($("#startPoint").val());
    		if(startPoint!= ""){
    			startPoint = startPoint+" 00:00:00";
    		}
    		var endPoint = $.trim($("#endPoint").val());
    		if(endPoint!=""){
    			endPoint = endPoint+" 23:59:59";
    		}
    		var status = $.trim($("#status").val());
    		var projId = $.trim($("#projectId").val())
    		$("#gridlist").jqGrid('setGridParam',{  
    	        datatype:'json',
    	        postData:{"sysNoticeTitle":sysNoticeTitle, "startPoint":startPoint, "endPoint":endPoint, "status": status,"projId":projId},
    	        page : (page || 1)
    	    }).trigger("reloadGrid"); //重新载入  
    	}
    
        $(function () {
            $("#gridlist").jqGrid({
                url: "getSysNoticeList.html?projId=${projId }",
                mtype: "post",
                datatype: "json",
                autowidth: true,
                height: 270,
                colNames: [
                    '操作',
                    '公告id',
                    '公告code',
                    '项目id',
                    '所属项目',
                    '标题',
                    '发布机构',
                    '内容',
                    '阅读次数',
					'发布日期', 
					'url',
					'更新日期',
					'更新人',
					'状态'
					
                ],
                colModel: [
                   { name: 'operate', width: 140, align:"center", sortable: false,
	                   formatter : function(val, opts, rowdata) {
	                      	var str=""
		                 if(rowdata.status!=1){
    		             str +=  "<a href='toEditSysNotice.html?sysNoticeId=" + rowdata.sysNoticId + "&opType=1&projId="+rowdata.projId+"' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat 0px 0px' class='opIcon' title='编辑'></a>";
		                 }
    	                  if(rowdata.url==""||rowdata.url==null){
				         str += "<a href='toSysNoticeDetial.html?sysNoticeId=" + rowdata.sysNoticId + "&projId="+rowdata.projId+"' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -100px 0px' class='opIcon' title='详情'></a>";
    	                  }else{
    	               	str += "<a href='javascript:url(\"" + rowdata.url + "\");' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -100px 0px' class='opIcon' title='详情'></a>";
    	                }
			             str += "<a href='toSysNoticeLogList.html?sysNoticeId=" + rowdata.sysNoticId + "&projId="+rowdata.projId+"' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -120px 0px' class='opIcon' title='维护记录'></a>";
                    	return str;
                    }},
                    { name: 'sysNoticId',hidden:true, width: 100, align:"center", sortable: false},
                    { name: 'sysNoticeCode',hidden:true, width: 120, align:"center", sortable: false },
                    { name: 'projId',hidden:true, width: 120, align:"center", sortable: false },
                    { name: 'projName',hidden:true, width: 180, align:"left", sortable: false },
                    { name: 'title', width: 180, align:"left", sortable: false},
                    { name: 'org',width: 160, align:"left", sortable: false},
                    { name: 'content',hidden:true, width: 110, align:"center", sortable: false},
                    { name: 'readCount',hidden:true, width: 60, align:"center", sortable: false},
                    { name: 'dateTime', width: 160, align:"center", sortable: false},
                    { name: 'url',hidden:true, width: 110, align:"center", sortable: false},
                    { name: 'updDateTime',hidden:true, width: 160, align:"center", sortable: false},
                    { name: 'updUser',hidden:true, width: 110, align:"center", sortable: false},
                    { name: 'status', width: 40, align: 'center', sortable: false,
                    	formatter : function(val, opts, rowdata) {
                    		var strSta = "";
                    		if(rowdata.status == 1){
                    			strSta += "已发布";
                    		}else{
                    			strSta += "未发布";
                    		}
                    		return strSta;
                    	}
                    }
                    
                ],
                rowNum: 20,
                rowList: [10, 20, 50, 100],
                rownumbers: true,
                pager: "#gridpage",
                multiselect: true, 
                viewrecords: true,
                caption: "${bidProject.name}-公告列表",
                jsonReader: {
                    id: "hospId"
                }
            });
            
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
            $("#projectId").val("${projId}");
            
        });
    </script>
</body>
</html>












